package com.shd.edanpei.util.contact;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by mc on 2018/11/15.
 * yang-wen-wen
 */

public class ContactBean implements Parcelable {

    private String name;
    private String mobile;
    private long createTime;
    private int createUserId;
    private long friendId;
    private String picUrl;
    private int sex;


    public ContactBean(String name, String mobile) {
        this.name = name;
        this.mobile = mobile;
    }

    protected ContactBean(Parcel in) {
        name = in.readString();
        mobile = in.readString();
        createTime = in.readLong();
        createUserId = in.readInt();
        friendId = in.readLong();
        picUrl = in.readString();
        sex = in.readInt();
    }

    public static final Creator<ContactBean> CREATOR = new Creator<ContactBean>() {
        @Override
        public ContactBean createFromParcel(Parcel in) {
            return new ContactBean(in);
        }

        @Override
        public ContactBean[] newArray(int size) {
            return new ContactBean[size];
        }
    };

    public String getName() {
        return name;
    }

    public String getMobile() {
        return mobile;
    }

    public long getCreateTime() {
        return createTime;
    }

    public int getCreateUserId() {
        return createUserId;
    }

    public long getFriendId() {
        return friendId;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public String getGender() {
        return sex == 0 ? "男" : "女";
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(mobile);
        dest.writeLong(createTime);
        dest.writeInt(createUserId);
        dest.writeLong(friendId);
        dest.writeString(picUrl);
        dest.writeInt(sex);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;

        if (obj == null)
            return false;

        if (getClass() != obj.getClass())
            return false;

        ContactBean other = (ContactBean) obj;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;

        if (mobile == null) {
            if (other.mobile != null)
                return false;
        } else if (!mobile.equals(other.mobile))
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        result = prime * result + ((mobile == null) ? 0 : mobile.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return (name + "&" + mobile).replace(" ","");
    }
}
